package org.ahmadsoft.ropes.impl;

import java.util.Iterator;

final class CharSequenceIterator implements Iterator<Character> {

	int current;
	final CharSequence sequence;
	final int length;

	CharSequenceIterator(CharSequence sequence, int start) {
		current = start;
		this.sequence = sequence;
		this.length = sequence.length();
	}

	public boolean hasNext() {
		return this.current < length;
	}

	public Character next() {
		return sequence.charAt(this.current++);
	}

	public void remove() {
		throw new UnsupportedOperationException("Rope iterator is read-only.");
	}

}
